package com.zengfa.task.client.support;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zengfa.task.api.enums.JobStatus;
import com.zengfa.task.api.model.JobDTO;
import com.zengfa.task.api.model.JobNodeDTO;
import com.zengfa.task.api.service.ServerApiService;

@Service
public class ServerApiSupport {

	@Autowired
	private ServerApiService serverApiService;
	
	public JobDTO createTask(JobDTO jobDTO) {
		return serverApiService.createTask(jobDTO);
	}
	
	public void resetJob(String jobId) {
		serverApiService.resetJob(jobId);
	}
	
	public JobNodeDTO getNextRunNode(String jobId) {
		return serverApiService.getNextRunNode(jobId);
	}
	
	public JobNodeDTO getCurrentRunNode(String jobId) {
		return serverApiService.getCurrentRunNode(jobId);
	}
	
	public Boolean saveJobNodeStatus(JobNodeDTO jobNode, JobStatus status, String message) {
		return serverApiService.saveJobNodeStatus(jobNode, status, message);
	}
	
	/**
	 * 单任务操作
	 */
	public Boolean saveJobStatus(JobDTO jobDTO, JobStatus status, String message) {
		return serverApiService.saveJobStatus(jobDTO, status, message);
	}
	
	public JobDTO getJob(String jobId) {
		return serverApiService.getJob(jobId);
	}
	
	public void stopJob(String bizType,String bizId) {
		serverApiService.stopJobByBiz(bizType, bizId);
	}
	
	public void saveJobHeartbeat(String jobId) {
		
	}

}
